package org.common.middlewave;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.common.middlewave.RequestInterceptor;

/**
 * 拦截器的注册
 */


@Configuration
public class RegisterInterceptor implements WebMvcConfigurer{
    @Autowired
    private RequestInterceptor requestInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(requestInterceptor)
                .addPathPatterns("/**") // 拦截所有路径，可以根据需要添加具体的路径模式
                .excludePathPatterns("/error", "/webjars/**", "/swagger-resources/**", "/v2/api-docs", "/h2-console/**"); // 排除不需要拦截的路径
    }

}
